import os

from flask import Flask, render_template, request,jsonify

from get_html import html_search
from sql_select import get_leiji, das
import time

from sql_updata import update_das

app = Flask(__name__)
app.debug = False


@app.route('/')
def hello_world1():
    return render_template('股票.html')


@app.route('/world',methods=['GET', 'POST', 'PUT'])
def hello_world():
    return render_template('map_world.html')


@app.route('/ss',methods=['GET', 'POST', 'PUT'])
def Ch_search():
    sous = request.values.get("search")
    html_search(sous)
    return render_template('map_c.html')


@app.route('/time', methods=['GET', 'POST', 'PUT'])
def get_time():
    time_str = time.strftime("%Y{}%m{}%d{} %X")
    return time_str.format("年", "月", "日")


@app.route('/打赏')
def hello_world2():
    update_das(das()[0])
    newn = das()
    return jsonify("当前点赞人数：{}".format(newn[0]))


@app.route('/login', methods=['GET', 'POST', 'PUT'])
def login():
    return render_template('index.html')


@app.route('/leiji',methods=['GET', 'POST', 'PUT'])
def leiji():
    data = get_leiji()
    return jsonify({"nowConfirm":data[0],"confirm":data[1],"dead":data[2],"heal":data[3]})

if __name__ == '__main__':
    app.run(host="0.0.0.0")
